﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TSWR
    {
        #region ==WEAVER===========
        public static readonly DependencyProperty WEAVERProperty = DependencyProperty.Register("WEAVER",
            typeof(string), typeof(TSWR),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWEAVERChanged));
        public string WEAVER
        {
            get
            {
                return (string)GetValue(WEAVERProperty);
            }
            set
            {
                SetValue(WEAVERProperty, value); 
            }
        }

        private static void OnWEAVERChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TSWR;
            if (src != null)
            {
                src.WEAVER = (string)e.NewValue;
            }
        }
        #endregion
        public TSWR()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VHRSTAMM(); 
            this.DataContext = MV; 
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if(dwMaster==null)
            {
                WEAVER = "";
            }
            else
            {
                WEAVER = TMV.HRBENID.PadRight(10) + TMV.HRNNAME.PadRight(10);
            }
        }
        public virtual void ComboBox_DropDownOpened(object sender, EventArgs e)
        {
            KEY = "";
            WEAVER = "";
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            LOADALL();
            base.Window_Loaded(sender, e);
           
        }
        public override void LOADALL()
        {
            dwData = TBMain.NewRow();
            dwData["HRMANDANT"] = app.Mandant;
            dwData["HRBGRP"] = "WV";
            SResult = TMV.QHR07(dwData);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["DES"] = Helpers.Helper.GetGB2312Value(row["DES"].ToString()); 
            }
            MergeData(SResult, false);
          
            Locate("KEY", EXAUF);  
    }
        public override void LOADBYAUF()
        {
            Locate("KEY", ORDERNUM); 
        }
        public override void OnEXAUFChg(string vlaue)
        {
            Locate("KEY", EXAUF);
            base.OnEXAUFChg(vlaue);
        }
    }
}
